//
//  TipsVC.m
//  LQTutor
//
//  Created by 李亚琪 on 2017/6/2.
//  Copyright © 2017年 mingthink. All rights reserved.
//

#import "TipsVC.h"
#import "MeEditInfoVC.h"

@interface TipsVC ()

@property(nonatomic,strong)UIView *view_authority;
@property(nonatomic,strong)UIView *view_wait;

@end

@implementation TipsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self showView];
}

#pragma mark- 加载数据
-(void)loadData
{
    [HttpManager requestWithProgressTitle:nil method:HTTPS_POST path:URL_GET_TEACHER_STATUS paramDict:nil finishBlock:^(id result, AFHTTPRequestOperationManager *manager) {
        [self.view_wait removeFromSuperview];
        [self.view_authority removeFromSuperview];
        //    -1   UnAudited,0       未审核       Approved,1       审核通过       Reject,2       审核未通过       Disable,3       禁用
        int status = [result[@"Data"] intValue];
        if (status == -1){
            //未提交过申请
        }else if (status == 0){
            //未审核
            [self.view addSubview:self.view_wait];
        }else if (status == 1){
            //审核通过
        }else if (status == 1){
            //审核未通过
            [self.view addSubview:self.view_authority];
        }
    }];
}

#pragma mark- 显示视图
-(void)showView{
    self.title = @"登录";
    
    [self.view addSubview:self.view_wait];
}


-(UIView *)view_authority{
    if (!_view_authority){
        UIView *view_authority = [[UIView alloc] initWithFrame:CGRectMake(0, NAVBAR_HEIGH, DEVW, DEVH-NAVBAR_HEIGH)];
        view_authority.backgroundColor = GET_HEX_COLOR(TABLE_SEPARATOR_CONTENT);
        
        UIImageView *imgv_user = UIImageView.new;
        [view_authority addSubview:imgv_user];
        imgv_user.contentMode = UIViewContentModeScaleAspectFit;
        imgv_user.image = [UIImage imageNamed:@"sb"];
        imgv_user.sd_layout.centerXEqualToView(view_authority).widthIs(100).heightIs(100).topSpaceToView(view_authority,100);
        
        UILabel *lab_detail = UILabel.new;
        [view_authority addSubview:lab_detail];
        lab_detail.textAlignment = NSTextAlignmentCenter;
        lab_detail.text = @"很抱歉！审核失败~~";
        lab_detail.font = GET_SYSTEM_FONT(TEXT_FONT_32);
        lab_detail.textColor = GET_HEX_COLOR(TEXT_DEEP_BLACK);
        lab_detail.sd_layout.topSpaceToView(imgv_user,20).widthIs(180).centerXEqualToView(view_authority).autoHeightRatio(0);
        
        UIView *view_line = UIView.new;
        [view_authority addSubview:view_line];
        view_line.backgroundColor = GET_HEX_COLOR(TABLE_SEPARATOR_LIGHTGRAY);
        view_line.sd_layout.topSpaceToView(lab_detail,20).widthIs(180).centerXEqualToView(view_authority).heightIs(1);
        
        UILabel *lab_detail2 = UILabel.new;
        [view_authority addSubview:lab_detail2];
        lab_detail2.textAlignment = NSTextAlignmentCenter;
        //lab_detail2.text = @"您可以在成为导师后\n加微信号 : 17718455044 申请认证";
        lab_detail2.font = GET_SYSTEM_FONT(TEXT_FONT_32);
        lab_detail2.textColor = GET_HEX_COLOR(TEXT_GRAY);
        lab_detail2.sd_layout.topSpaceToView(view_line,20).widthIs(260).centerXEqualToView(view_authority).autoHeightRatio(0);
        
        NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:@"由于您的身份信息不详,\n请修改资料后重新提交申请！"];
        [attrStr setAttributes:@{NSForegroundColorAttributeName:GET_HEX_COLOR(TEXT_GRAY)} range:NSMakeRange(0, attrStr.length)];
        lab_detail2.attributedText = attrStr;
        
        UIButton *btn_authority = [UIButton buttonWithType:UIButtonTypeCustom];
        [view_authority addSubview:btn_authority];
        [btn_authority setTitle:@"去修改资料" forState:UIControlStateNormal];
        [btn_authority setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn_authority.titleLabel.font = GET_SYSTEM_FONT(TEXT_FONT_32);
        btn_authority.layer.cornerRadius = 6;
        btn_authority.layer.backgroundColor = GET_HEX_COLOR(CELL_LABLE_BORDER_RED).CGColor;
        [btn_authority addTarget:self action:@selector(modifyInfoClick) forControlEvents:UIControlEventTouchUpInside];
        btn_authority.sd_layout.centerXEqualToView(view_authority).heightIs(40).widthIs(160).topSpaceToView(lab_detail2,30);
        
        _view_authority = view_authority;
    }
    return _view_authority;
}

-(UIView *)view_wait{
    if (!_view_wait){
        UIView *view_authority = [[UIView alloc] initWithFrame:CGRectMake(0, NAVBAR_HEIGH, DEVW, DEVH-NAVBAR_HEIGH)];
        view_authority.backgroundColor = GET_HEX_COLOR(TABLE_SEPARATOR_CONTENT);
        
        UIImageView *imgv_user = UIImageView.new;
        [view_authority addSubview:imgv_user];
        imgv_user.contentMode = UIViewContentModeScaleAspectFit;
        imgv_user.image = [UIImage imageNamed:@"dd"];
        imgv_user.sd_layout.centerXEqualToView(view_authority).widthIs(100).heightIs(100).topSpaceToView(view_authority,100);
        
        UILabel *lab_detail = UILabel.new;
        [view_authority addSubview:lab_detail];
        lab_detail.textAlignment = NSTextAlignmentCenter;
        lab_detail.text = @"成为导师申请已经提交\n请耐心等待~~";
        lab_detail.font = GET_SYSTEM_FONT(TEXT_FONT_32);
        lab_detail.textColor = GET_HEX_COLOR(TEXT_DEEP_BLACK);
        lab_detail.sd_layout.topSpaceToView(imgv_user,20).widthIs(180).centerXEqualToView(view_authority).autoHeightRatio(0);
        
        UIView *view_line = UIView.new;
        [view_authority addSubview:view_line];
        view_line.backgroundColor = GET_HEX_COLOR(TABLE_SEPARATOR_LIGHTGRAY);
        view_line.sd_layout.topSpaceToView(lab_detail,20).widthIs(180).centerXEqualToView(view_authority).heightIs(1);
        
        UILabel *lab_detail2 = UILabel.new;
        [view_authority addSubview:lab_detail2];
        lab_detail2.textAlignment = NSTextAlignmentCenter;
        //lab_detail2.text = @"您可以在成为导师后\n加微信号 : 17718455044 申请认证";
        lab_detail2.font = GET_SYSTEM_FONT(TEXT_FONT_32);
        lab_detail2.textColor = GET_HEX_COLOR(TEXT_GRAY);
        lab_detail2.sd_layout.topSpaceToView(view_line,20).widthIs(260).centerXEqualToView(view_authority).autoHeightRatio(0);
        
        NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:@"我们会在3个工作日内完成身份审核,\n感谢您对录趣的支持!"];
        [attrStr setAttributes:@{NSForegroundColorAttributeName:GET_HEX_COLOR(TEXT_GRAY)} range:NSMakeRange(0, attrStr.length)];
        lab_detail2.attributedText = attrStr;
        
        _view_wait = view_authority;
    }
    return _view_wait;
}

#pragma mark -- 去修改资料
-(void)modifyInfoClick{
    MeEditInfoVC *vc = MeEditInfoVC.new;
    vc.type = EditInfoTypeEdit;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self loadData];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
